<template>
    <transition name="slide-up">
        <div class="setting-wrapper" v-show="menuVisible && settingVisible === 1">
            <!-- <div class="setting-font-size" v-if="showTag === 0">
                <div class="preview" :style="{fontSize: fontSizeList[0].fontSize + 'px'}">A</div>
                <div class="select">
                    <div class="select-wrapper" v-for="(item, index) in fontSizeList" :key="index" @click="setFontSize(item.fontSize)">
                        <div class="line"></div>
                        <div class="point-wrapper">
                            <div class="point"  v-show="defaultFontSize === item.fontSize">
                                <div class="small-point"></div>
                            </div>
                        </div>
                        <div class="line"></div>
                    </div>
                </div>
                <div class="preview" :style="{fontSize: fontSizeList[fontSizeList.length - 1].fontSize + 'px'}">A</div>
            </div> -->
            <div class="setting-theme">
                <div class="setting-theme-item" v-for="(item, index) in themeList" :key="index" @click="setTheme(index)">
                    <div class="preview" :class="{'selected': item.name === defaultTheme}" :style="{background: item.style.body.background}"></div>
                    <div class="text" :class="{'selected': item.name === defaultTheme}">{{item.alias}}</div>
                </div>
            </div>
            <!-- <div class="setting-progress" v-if="showTag === 2">
                <div class="progress-wrapper">
                    <input class="progress" type="range"
                                            max="100"
                                            min="0"
                                            step="1"
                                            @change="onProgressChange($event.target.value)"
                                            @input="onProgressInput($event.target.value)"
                                            :value="progress"
                                            :disabled="!bookAvailable"
                                            ref="progress">
                    <div class="text-wra">
                        <span>{{bookAvailable ? progress + '%' : '加载中...'}}</span>
                    </div>
                </div>
            </div> -->
        </div>
    </transition>
</template>

<script>
    import { ebookMixin } from '../../utils/mixin'
    import { saveTheme } from '../../utils/localStorage'

    export default {
        mixins: [ebookMixin],
        methods: {
            setTheme(index) {
                const theme = this.themeList[index]
                this.setDefaultTheme(theme.name).then(() => {
                    this.currentBook.rendition.themes.select(this.defaultTheme)
                })
                saveTheme(this.fileName, theme.name)
            }
        },
    }
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
    @import '../../assets/styles/global';
    .setting-wrapper {
        position: absolute;
        bottom: px2rem(48);
        left: 0;
        z-index: 101;
        display: flex;
        width: 100%;
        height: px2rem(60);
        background: #ffffff;
        box-shadow: 0 px2rem(-8) px2rem(8) rgba(0,0,0,0.15);
        .setting-theme {
            width: 100%;
            height: 100%;
            display: flex;
            .setting-theme-item {
                flex: 1;
                display: flex;
                flex-direction: column;
                padding: px2rem(5);
                box-sizing: border-box;
                .preview {
                    flex: 1;
                    box-sizing: border-box;
                    &.selected {
                        box-shadow: 0 px2rem(4) px2rem(6) 0 rgba(0, 0, 0, .1)
                    }
                }
                .text {
                    flex: 0 0 px2rem(20);
                    font-size: px2rem(14);
                    color: #ccc;
                    @include center;
                }
                .selected {
                    color: #333;
                }
            }
        }
    }

</style>